#include<bits/stdc++.h>
using namespace std;
int n,s,t,sum;
struct node
{
	int num,l,next;
}a[200005];
inline long long read()
{
	char c=getchar();
	int f=1;
	long long sum=0;
	while(c!='-'&&(c<'0'||c>'9'))c=getchar();
	if(c=='-')
	{
		f=-1; 
		c=getchar();
	} 
	do
	{
		sum=(sum<<3)+(sum<<1)+c-'0'; 
		c=getchar();
	}while(c>='0'&&c<='9');
	return sum*f;
}
int main()
{
	freopen("fruit.in","r",stdin);
	freopen("fruit.out","w",stdout);
	n=read();
	s=1,t=n;
	for(int i=1;i<=n;i++)
	{
		a[i].num=read();
		a[i].l=i-1;
		a[i].next=i+1;
	} 
	while(sum!=n)
	{
		int k=-1;
		for(int i=s;i<=t;i=a[i].next)
		{
			if(a[i].num!=k)
			{
				k=a[i].num;
				sum++;
				cout<<i<<' ';
				a[a[i].next].l=a[i].l;
				a[a[i].l].next=a[i].next;
				if(i==s)
				{
					s=a[i].next;
				}
				if(i==t)
				{
					t=a[i].l;
				}
			}
		}
		cout<<endl;
	}
} 
